package com.DongBing.common.Handler;

import com.DongBing.common.exception.DongBingException;
import com.DongBing.common.utils.Res;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionHandler {

    @org.springframework.web.bind.annotation.ExceptionHandler(Exception.class)
    @ResponseBody
    public Res<?> error(Exception e){
        e.printStackTrace();
        return Res.error("系统异常,请稍后再试");
    }

    @org.springframework.web.bind.annotation.ExceptionHandler(DongBingException.class)
    @ResponseBody
    public Res<?> error(DongBingException e){
        e.printStackTrace();
        return Res.error(e.getMessage());
    }

}
